home *** CD-ROM | disk | FTP | other *** search
/ Hráč 2004 August / Hrac_72_2004-08_dvd.iso / dema / Rapid Gun / rg_setup.exe / common / image_SaturationFilter.fx < prev    next >
Text File  |  2004-04-19  |  2KB  |  82 lines

  1. // LF2 Engine
  2. // (C) 2002-3 7FX
  3. //---------------------------------------------------------------------------
  4. // Desc
  5. string desc : Description = "Image shader - color saturation.";
  6. // Shader type phase
  7. string type : Type = "image";
  8. //---------------------------------------------------------------------------
  9. // Render target texture
  10. texture RT : RenderTargetFSMap;
  11. //---------------------------------------------------------------------------
  12. sampler sRT = sampler_state
  13. {
  14.     Texture = <RT>;
  15.     MinFilter = POINT;
  16.     MagFilter = POINT;
  17.     AddressU = CLAMP;
  18.     AddressV = CLAMP;
  19. };
  20. //---------------------------------------------------------------------------
  21. // Constants
  22. const float4 cLum = {0.3f, 0.59f, 0.11f, 1.f};
  23. const float4 c0 =   {1.0, 1.0, 1.0, 1.0};
  24.  
  25. // Pixel shader
  26. float4 PS(float2 uv: TEXCOORD0) : COLOR
  27. {
  28.     float4 samp = tex2D(sRT, uv);
  29.     
  30.     float4 r0 = samp;
  31.     r0.rgb = saturate(4 * (2 * (samp.rgb - 0.5f)));
  32.     float4 r1 = saturate(dot(r0.rgb, c0.rgb));
  33.      
  34.     r1.rgb = dot(samp.rgb, cLum.rgb);
  35.     
  36.     r0.rgb = lerp(r1.rgb, r0.rgb, r1.a);
  37.     return r0;
  38. }
  39. //---------------------------------------------------------------------------
  40. technique vs0_ps20
  41. {
  42.     pass p0
  43.     {
  44.            ZEnable = false;
  45.         ZWriteEnable = false;
  46.    
  47.         PixelShader  = compile ps_2_0 PS();
  48.     }
  49. }
  50. //---------------------------------------------------------------------------
  51. technique vs0_ps11
  52. {
  53.     pass p0
  54.     {
  55.            ZEnable = false;
  56.         ZWriteEnable = false;
  57.    
  58.         Sampler[0] = <sRT>;
  59.    
  60.         PixelShaderConstantF[0] = <c0>;
  61.         PixelShaderConstantF[1] = <cLum>;
  62.    
  63.         PixelShader  = asm
  64.         {
  65.             ps.1.1
  66.             
  67.             tex t0
  68.             
  69.             // saturate
  70.             mov_x4_sat r0.rgb, t0_bx2
  71.             dp3_sat r1.rgba, r0, c0
  72.             // grayscale
  73.             dp3 r1.rgb, t0, c1
  74.             // interpolate between color and grayscale
  75.             lrp r0.rgb, r1.a, r0, r1
  76.             // output alpha
  77.             + mov r0.a, t0.a
  78.         };
  79.     }
  80. }
  81. //---------------------------------------------------------------------------
  82.